﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

// background repeat
public class BGRepeat : MonoBehaviour {
	BoxCollider2D bgCollider;
	float groundWidth;

	// Use this for initialization
	void Start () {
		bgCollider = GetComponent<BoxCollider2D> ();
		groundWidth = bgCollider.size.x;
	}
	
	// Update is called once per frame
	void Update () {
		if (transform.position.x < -groundWidth) {
			Vector2 offset = new Vector2 (groundWidth * 2f, 0);
			transform.position = (Vector2)transform.position + offset;
		}
	}
}
